﻿#region Creditos

/* Autor: Edilberto Sánchez Forero	*/
/* Email: esanchezfo@gmail.com		*/
/* Licencia: LGPL, Software Libre	*/
/* País: Colombia, Bogotá			*/

#endregion
#region Librerias

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

#endregion


namespace ESF.Peer.Configuration
{
	[ConfigurationCollection (typeof (RequestHandlerElement))]  
	public class RequestHandlersCollection : ConfigurationElementCollection
	{
		#region Propiedades
		
		public RequestHandlerElement this[int index]
		{
			get 
			{
				return (RequestHandlerElement) BaseGet(index); 
			}
			set
			{
				if (BaseGet(index) != null)
					BaseRemoveAt(index);
					
				BaseAdd(index, value);
			}
		}
		
		
		new public RequestHandlerElement this[string Name]
		{
			get
			{
				return (RequestHandlerElement)BaseGet(Name);
			}
		}
		
		#endregion
		
		
		#region Funciones
		
		

		public int IndexOf(RequestHandlerElement url)
		{
			return BaseIndexOf(url);
		}

		
		public void Add(RequestHandlerElement url)
		{
			BaseAdd(url);
		}
		
		
		protected override void BaseAdd(ConfigurationElement element)
		{
			BaseAdd(element, false);
		}
		

		public void Remove(RequestHandlerElement url)
		{
			if (BaseIndexOf(url) >= 0)
				BaseRemove(url.appName);
		}
		
		
		protected override ConfigurationElement CreateNewElement()
		{
			return new RequestHandlerElement();
		}
		
		
		protected override object GetElementKey (ConfigurationElement pElement)
		{
			return ((RequestHandlerElement) pElement).appName;
		}
		
		#endregion
	}
}